from src.com.ydzy.util.sql_util import MySQLUtils




db = MySQLUtils('192.168.8.234', 3306, 'root', 'root', 'test-zh')
db_doris = MySQLUtils('192.168.9.32', 9030, 'root', 'Mdsoss@123', 'test')

table_name='fact_sale'
total = db.retrieve_count(table=table_name, condition=None)
print(f"数据量总数为{total}")
pagenum = 10000
page = int(total / pagenum) if total % pagenum == 0 else int(total / pagenum) + 1
query_sql = "SELECT id,sale_date,prod_name,sale_nums FROM fact_sale  limit %s offset %s"
result = []
for i in range(page):
    startIndex = pagenum * i
    datas=db.retrieve_json(table=table_name,condition='1=1 limit %s offset %s '%(pagenum, startIndex))
    db_doris.insertBatch(table='ods_fact_sale_doris',keys=list(datas[0].keys()),data=datas)
    print(f"总页码为{page}当前完成进度为{(((i + 1) / page))}%")


